package com.czapl.drawing;

import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
import com.badlogic.gdx.math.Matrix4;
import com.badlogic.gdx.math.Vector2;

public class ConditionBar {
	private static final float BAR_HEIGHT = 3;
	private ShapeRenderer m_shapeRenderer;
	private Vector2 m_size;
	private float m_maxHp;
	private float m_currentHp;
	
	public ConditionBar(float maxHp) {
		m_shapeRenderer = new ShapeRenderer();
		m_size = new Vector2();
		m_maxHp = maxHp;
		m_currentHp = m_maxHp;
	}
	
	public void setHp(float currentHp) {
		m_currentHp = currentHp;
	}
	public void setSize (float width, float height) {
		m_size.x = width;
		m_size.y = height;
	}
	
	public void draw (Matrix4 combined, float x, float y) {
		m_shapeRenderer.setProjectionMatrix(combined);
		m_shapeRenderer.setColor(Color.RED);
		m_shapeRenderer.begin(ShapeType.Filled);
		m_shapeRenderer.rect(x, y+m_size.y-BAR_HEIGHT, m_size.x, BAR_HEIGHT);
		m_shapeRenderer.end();
		m_shapeRenderer.setColor(Color.GREEN);
		m_shapeRenderer.begin(ShapeType.Filled);
		m_shapeRenderer.rect(x, y+m_size.y-BAR_HEIGHT, m_currentHp/m_maxHp*m_size.x, BAR_HEIGHT);
		m_shapeRenderer.end();
	}
	
}
